package com.snopy.java8.stream;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname StreamDemo
 * @description
 * @email 77912204@qq.com
 * @date 2022/04/10 0:20
 */
public class StreamDemo {
    public static void main(String[] args) {
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            User user = new User("user1",18+i,1000.0*(1+0.1*i));
            list.add(user);
        }
        final int sum = list.stream().filter(user -> user.getSalary() > 1100)
                .sorted(Comparator.comparingInt(User::getAge))
                .mapToInt(value -> {
                    return value.getAge() - 18;
                }).sum();

    }
}
